<template xmlns="http://www.w3.org/1999/html">
  <sea-data-table ref="tableObject" url="/sys/excel/page">
    <!--表头-->
    <sea-table-header slot="header">
      <!--标题栏-->
      <sea-table-title slot="title" title="Excel管理" subtitle="当前界面包含用户本人的上传的所有Excel信息"></sea-table-title>

      <!--输入-->
      <template slot="input">
        <smart-form-layout require name="keyword" label="关键字" :span="6">
          <smart-text-view name="keyword" placeholder="keyword"></smart-text-view>
        </smart-form-layout>
      </template>

      <!--按钮栏-->
      <template slot="buttons">
        <el-button plain size="small" title="新增" icon="fa fa-plus" @click="onAction('new')"></el-button>
      </template>
    </sea-table-header>

    <!--表头-->
    <template slot="columns">
      <sea-col-link property="excelName" label="文件名" width="240"
                       :click="onAction" show-overflow-tooltip ></sea-col-link>
      <el-table-column property="excelPath" label="存储路径"></el-table-column>
      <el-table-column property="excelStatus" label="状态" width="120"></el-table-column>
      <el-table-column property="excelType" label="文件类型" width="120"></el-table-column>
      <el-table-column property="gmtCreate" label="创建日期" width="180"></el-table-column>
      <el-table-column property="gmtModified" label="更新日期" width="180"></el-table-column>

      <!--操作栏-->
      <sea-table-actionbar width="220" :on-action="onAction" :buttons="buttons"></sea-table-actionbar>
    </template>

    <!-- 弹窗、抽屉 -->
    <template slot="drawer">
      <sea-dialog ref="content_dialog">
        <excel-content ref="content"></excel-content>
      </sea-dialog>
      <sea-dialog ref="log_dialog">
        <log-list ref="log" :object="row_data"></log-list>
      </sea-dialog>
    </template>
<!--    <template slot="drawer">-->
<!--      <excel-content ref="panel_content"></excel-content>-->
<!--      <log-list ref="log_content"></log-list>-->
<!--    </template>-->
  </sea-data-table>
</template>

<script>
import ExcelContent from './content'
import LogList from "./log";

export default {
    components: {
        ExcelContent, LogList
    },
    data() {
        return {
            // 操作名称
            operation: undefined
            // 当前操作的行级对象
            , row_data: undefined
            // 操作栏
            , buttons: [
                {type: 'btn', evt: 'download', label: '下载', title: '查看当前行'}
                , {type: 'btn', evt: 'info', label: '查看', title: '查看文件上传之后的数据导入情况'}
                , {type: 'btn', evt: 'history', label: '日志', title: '查看文件上传之后的数据导入情况'}
                , {type: 'divider'}
                , {type: 'btn', evt: 'remove', label: '删除', style: 'text-orange', title: '删除当前行'}
            ]
            // end--
        }
    },
    methods: {
        /**
         * 操作成功回调
         */
        onSucceed: function () {
            this.$refs.tableObject.reload();
        },
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         * @param old 可供回滚的参数
         */
        onAction: function (evt, row, old) {
            console.log(evt)
            if(evt === 'info' || evt === '$excelName'){
                let dialog = {title: row.excelName, fullscreen: true};
                this.$refs.content_dialog.open(dialog).then(() => {
                    this.row_data = row;
                    this.where = {id: row.id};
                });
            } else {
                let dialog = {title: row.excelName, fullscreen: true};
                this.$refs.log_dialog.open(dialog).then(() => {
                    this.row_data = row;
                });
            }
        }
    }
}
</script>
